Package edu.uky.ai.csp.kr
Class Problem
java.lang.Object
edu.uky.ai.csp.kr.Problem
- Direct Known Subclasses:
MapColoring,Sudoku
public class Problem
extends java.lang.Object
A constraint satisfaction problem is composed of variables (each with a set
of potential values called a domain) and constraints on the values those
variable can be assigned.
- Author:
- Stephen G. Ware
-
Field Summary
Fields Modifier and Type Field Description java.lang.Iterable<Constraint>constraintsA set of all the constraints that a solution to this problem must meetjava.lang.Iterable<Variable>variablesA set of all the variables defined for this problem -
Constructor Summary
Constructors Constructor Description Problem() -
Method Summary
Modifier and Type Method Description voidaddConstraint(Constraint constraint)Adds a new constraint to the problem.voidaddVariable(Variable variable, Domain domain)Defines a new variable, along with all the possible values it can be assigned, for this problem.DomaingetDomain(Variable variable)Returns the set of possible values that a given variable can be assigned in the initial state of this problem.java.lang.StringtoString(Solution solution)Returns a problem-specific string representation of a potential solution.
-
Field Details
-
variables
A set of all the variables defined for this problem -
constraints
A set of all the constraints that a solution to this problem must meet
-
-
Constructor Details
-
Problem
public Problem()
-
-
Method Details
-
addVariable
Defines a new variable, along with all the possible values it can be assigned, for this problem.- Parameters:
variable- the new variable to be defineddomain- the possible values that variable can be assigned
-
getDomain
Returns the set of possible values that a given variable can be assigned in the initial state of this problem.- Parameters:
variable- the variable- Returns:
- the domain of that varaible in the initial state of the problem
-
addConstraint
Adds a new constraint to the problem.- Parameters:
constraint- the constraint
-
toString
Returns a problem-specific string representation of a potential solution.- Parameters:
solution- the solution to be rendered as a string- Returns:
- a string
-